# -*- coding: utf-8 -*-

# Copyright (c) Huoty, All rights reserved
# Author: Huoty <sudohuoty@163.com>
# CreateTime: 2020-10-30 14:19:56

import time
import threading
from timeout_decorator import timeout

def worker1():
    # 信号只能在主线程中注册，但不一定在主线程中被处理？
    @timeout(1)
    def foo():
        time.sleep(3)
        print("worker1 sleep done")

    foo()


def worker2():
    time.sleep(3)
    print("worker2 sleep done")


th1 = threading.Thread(target=worker1)
th2 = threading.Thread(target=worker2)
th3 = threading.Thread(target=worker2)

th1.start()
th2.start()
th3.start()

th1.join()
th2.join()
th3.join()
